package com.ruoyi.law.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageCondition;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.law.domain.entity.LawNotice;
import com.ruoyi.law.service.ILawNoticeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 播报管理 前端控制器
 * </p>
 *
 * @author code
 * @since 2022-12-13
 */
@Api(tags = "播报管理")
@RestController
@RequestMapping("/notice")
public class LawNoticeController extends BaseController {

    @Autowired
    private ILawNoticeService noticeService;

    @ApiOperation("列表")
    @GetMapping("/list")
    public R<Page<LawNotice>> list(PageCondition<LawNotice> pageCondition) {
        Page<LawNotice> page = noticeService.page(pageCondition.toPage());
        return R.ok(page);
    }

    @ApiOperation("详情")
    @GetMapping("/info")
    public R<LawNotice> info(Long id) {
        LawNotice lawNotice = noticeService.getById(id);
        return R.ok(lawNotice);
    }

    @ApiOperation("新增")
    @PostMapping("/save")
    public R<Object> save(@RequestBody LawNotice lawNotice) {
        noticeService.save(lawNotice);
        return R.ok();
    }

    @ApiOperation("修改")
    @PostMapping("/update")
    public R<Object> update(@RequestBody LawNotice lawNotice) {
        noticeService.updateById(lawNotice);
        return R.ok();
    }

    @ApiOperation("删除")
    @PostMapping("/delete")
    public R<Object> delete(@RequestBody Long id) {
        noticeService.removeById(id);
        return R.ok();
    }

}
